home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
system
/
sysprof3.zip
/
ORIGINAL.ARC
/
SYS_PROF.ASM
< prev
Wrap
Assembly Source File
|
1988-06-16
|
30KB
|
780 lines
;-----------------------------------------------------------------------------;
; ;
; Listing 1 ;
; ;
; NAME : SYS_PROF ;
; ;
; DATE : March 24, 1988 ;
; ;
; AUTHOR : (C) Copyright 1988 G. Kent Cobb - All Rights Reserved ;
; ;
; DESCRIPTION : ;
; This is the terminate-and-stay-resident portion of a system profiler. ;
; It installs several interrupt handlers, which monitor the occurrences ;
; and duration of a number of software interrupts. ;
; ;
;-----------------------------------------------------------------------------;
;----------------------------------------------------------------------------;
; Interrupt numbers ;
;----------------------------------------------------------------------------;
TIMER_INTERRUPT EQU 1CH
TERMINATE EQU 20H
TERM_AND_STAY_RES EQU 27H
CONTROL_INTERRUPT EQU 60H
;----------------------------------------------------------------------------;
; MS-DOS functions (Interrupt 21H services) ;
;----------------------------------------------------------------------------;
DOS MACRO OP
MOV AH,DOS_&OP
INT 21H
ENDM
DOS_DISPLAY_STRING EQU 09H
DOS_SET_INT_VECTOR EQU 25H
DOS_GET_INT_VECTOR EQU 35H
;----------------------------------------------------------------------------;
; This is a list of all the interrupts that are intercepted by SYS_PROF. ;
;----------------------------------------------------------------------------;
NUMBER_OF_INTERRUPTS EQU 9
PRINT_SCREEN_INTERRUPT EQU 5H
VIDEO_INTERRUPT EQU 10H
DISK_INTERRUPT EQU 13H
COMM_INTERRUPT EQU 14H
KEYBOARD_INTERRUPT EQU 16H
PRINTER_INTERRUPT EQU 17H
DOS_FUNC_INTERRUPT EQU 21H
ABS_DISK_READ_INTERRUPT EQU 25H
ABS_DISK_WRITE_INTERRUPT EQU 26H
;----------------------------------------------------------------------------;
; These are the number of distinct services defined for each interrupt. ;
; The OCCURRENCES array contains two double words for each service, and ;
; two additional double words for each interrupt. If an interrupt is ;
; generated with a service number that is out of range, the data for it ;
; will accumulate in this additional bin. ;
;----------------------------------------------------------------------------;
PRINT_SCREEN_SERVICES EQU 0
VIDEO_SERVICES EQU 20
DISK_SERVICES EQU 24
COMM_SERVICES EQU 4
KEYBOARD_SERVICES EQU 3
PRINTER_SERVICES EQU 3
DOS_FUNC_SERVICES EQU 99
ABS_DISK_READ_SERVICES EQU 0
ABS_DISK_WRITE_SERVICES EQU 0
;-----------------------------------------------------------------------;
; This macro defines the handling of the intercepted interrupts. The ;
; INT_NUM parameter that the macro expects is an index into the ;
; MAX_SERVICES and OFFSETS tables. ;
; ;
; Interrupts 25H and 26H are handled in a manner which is very ;
; similar, but slightly different from the other interrupts. If this ;
; macro is invoked with a second parameter, code is included to ;
; provide the special handling that these interrupts require. ;
;-----------------------------------------------------------------------;
PERFORM_INTERRUPT MACRO INT_NUM,SPECIAL
INTERRUPT_HANDLER&INT_NUM PROC FAR
; Turn interrupts back on.
STI
; Save the existing interrupt and service numbers on the stack.
PUSH CS:WORD PTR INTERRUPT
; Push the flags onto the stack now (before we execute any instructions which
; might change them) in order to simulate an interrupt later.
PUSHF
; Save the value of WATCH on the stack while we're changing INTERRUPT and
; SERVICE.
PUSH CS:WATCH
; Turn accumulation off, set new INTERRUPT and SERVICE values, make sure
; the service number is valid, and then restore accumulation to its previous
; state.
MOV CS:WATCH,0
MOV CS:INTERRUPT,&INT_NUM
MOV CS:SERVICE,AH
CALL VALIDATE_SERVICE
POP CS:WATCH
; If accumulation is turned off, go straight to the real ISR.
CMP CS:WATCH,0
JE READY_FOR_INTERRUPT&INT_NUM
; If accumulation is turned on, push a one onto the stack to tell the
; ACCUMULATE routine which bin to increment, and then call it.
PUSH CS:ONE
CALL ACCUMULATE
READY_FOR_INTERRUPT&INT_NUM:
; After tabulating occurrence data, execute the real ISR
CALL CS:DWORD PTR OLD_INTERRUPT_VECTORS [ 4*(&INT_NUM-1) ]
; Interrupts 25H and 26H require special handling. Since they leave the
; flags on the stack when they return control to the calling program, we
; have an extra word on the stack which must be popped.
IFNB <SPECIAL>
POP CS:EXTRA_FLAGS
ENDIF
; On return, pop the interrupt and service numbers that were current before
; this one.
POP CS:WORD PTR INTERRUPT
; For most interrupts, return with RET 2 rather than IRET. This will
; preserve whatever treatment the real ISR uses for the flags.
IFB <SPECIAL>
RET 2
; Interrupts 25H and 26H are special cases. The calling program expects the
; flags to still be on the stack, so we use RET instead.
ELSE
RET
ENDIF
INTERRUPT_HANDLER&INT_NUM ENDP
ENDM
CODE_SEG SEGMENT PUBLIC
ASSUME CS:CODE_SEG , DS:CODE_SEG
;-----------------------------------------------------------------------;
; This is the entry point for the program. Control is immediately ;
; transferred to the initialization code, which is located in the ;
; portion of the program which does not remain resident. ;
;-----------------------------------------------------------------------;
ORG 100H ; COM FILE
JUMP_TO_INIT PROC FAR
JMP INIT
JUMP_TO_INIT ENDP
;-----------------------------------------------------------------------------;
; The handling for all nine intercepted interrupts is very similar, and is ;
; defined by the PERFORM_INTERRUPT macro. This section contains the macro ;
; calls. ;
;-----------------------------------------------------------------------------;
; Print screen interrupt
PERFORM_INTERRUPT 1
; BIOS Video interrupt
PERFORM_INTERRUPT 2
; BIOS Disk interrupt
PERFORM_INTERRUPT 3
; BIOS Comm interrupt
PERFORM_INTERRUPT 4
; BIOS Keyboard interrupt (16H)
PERFORM_INTERRUPT 5
; BIOS Printer interrupt
PERFORM_INTERRUPT 6
; DOS Function calls interrupt
PERFORM_INTERRUPT 7
; The last two interrupts, 25H and 26H, require special handling since the
; real ISRs do not pop the flags from the stack upon completion. By passing
; a second parameter to the PERFORM_INTERRUPT macro, the code to handle this
; will be included by the preprocessor when the macro is expanded.
; DOS Ab